package com.android.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        findViewById(R.id.btn_file_path).setOnClickListener(this);
        findViewById(R.id.btn_text_write).setOnClickListener(this);//btn_text_write写入文本文件
        findViewById(R.id.btn_text_read).setOnClickListener(this);//读取文本文件
        findViewById(R.id.btn_image_write).setOnClickListener(this);
        findViewById(R.id.btn_image_read).setOnClickListener(this);

    }

    public void FourThreeOne(View view) {
        startActivity(new Intent(MainActivity.this, FileBasic.class));
    }

    @Override
    public void onClick(View v){
        if(v.getId() == R.id.btn_file_path){
        Intent intent = new Intent(this, FilePath.class);
        startActivity(intent);
        } else if (v.getId() == R.id.btn_text_write) {//btn_text_write写入文本文件
            Intent intent = new Intent(this, TextWrite.class);
            startActivity(intent);
        }else if (v.getId() == R.id.btn_text_read) {//读取文本文件
            Intent intent = new Intent(this, TextRead.class);
            startActivity(intent);
        }else if (v.getId() == R.id.btn_image_write) {
            Intent intent = new Intent(this, ImageWrite.class);
            startActivity(intent);
        } else if (v.getId() == R.id.btn_image_read) {
            Intent intent = new Intent(this, ImageRead.class);
            startActivity(intent);
        }
    }

}